import AMapLoader from "@amap/amap-jsapi-loader";

function initAMap() {
  window._AMapSecurityConfig = {
    securityJsCode: "ca1d53757ab1ec270138c1643a651e47",
  };

  // console.log(imageLayer);
  let that = this;
  AMapLoader.load({
    key: "0ba2408576fa3f7dc06311da2de61b6e", // 申请好的Web端开发者Key，首次调用 load 时必填
    version: "2.0", // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
    plugins: ["AMap.Scale"], //需要使用的的插件列表，如比例尺'AMap.Scale'，支持添加多个如：['...','...']
  })
    .then((AMap) => {
      that.AMap = AMap;
      let imageLayer = new AMap.ImageLayer({
        // url: "https://amappc.cn-hangzhou.oss-pub.aliyun-inc.com/lbs/static/img/dongwuyuan.jpg",
        url: require("@/assets/Home/OIPC1.jpg"),

        bounds: new AMap.Bounds([115.04, 38.54], [115.02, 38.53]),
        zooms: [11, 20],
      });
      that.map = new AMap.Map("Map", {
        // 设置地图容器id
        zoom: 16.5, // 初始化地图级别
        center: [115.03, 38.534], // 初始化地图中心点位置
        layers: [AMap.createDefaultLayer(), imageLayer],
      });
      this.LoadMarker();
      // that.map.add(imageLayer)
    })
    .catch((e) => {
      console.log(e);
    });
}
export { initAMap };
